﻿// Type: RoMBotDll.Database.ThreadedBindingList`1
// Assembly: RoMBotDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Assembly location: D:\Proyectos\TFS\Tests\RoMBotDll\bin\Debug\RoMBotDll.dll

using System.ComponentModel;
using System.Threading;

namespace RoMBot.Database
{
    public class ThreadedBindingList<T> : BindingList<T>
    {
        protected SynchronizationContext ctx = Bot.Instancia.Contexto;

        protected override void OnAddingNew( AddingNewEventArgs e )
        {
            if ( Bot.Instancia.Contexto == null )
                this.BaseAddingNew( e );
            else
                Bot.Instancia.Contexto.Send( ( SendOrPostCallback ) delegate
                {
                    this.BaseAddingNew( e );
                }, ( object ) null );
        }

        private void BaseAddingNew( AddingNewEventArgs e )
        {
            base.OnAddingNew( e );
        }

        protected override void OnListChanged( ListChangedEventArgs e )
        {
            if ( Bot.Instancia.Contexto == null )
                this.BaseListChanged( e );
            else
                Bot.Instancia.Contexto.Send( ( SendOrPostCallback ) delegate
                {
                    this.BaseListChanged( e );
                }, ( object ) null );
        }

        private void BaseListChanged( ListChangedEventArgs e )
        {
            base.OnListChanged( e );
        }

        protected override void ClearItems()
        {
            if ( Bot.Instancia.Contexto == null )
                this.BaseClearItems();
            else
                Bot.Instancia.Contexto.Send( ( SendOrPostCallback ) delegate
                {
                    this.BaseClearItems();
                }, ( object ) null );
        }

        private void BaseClearItems()
        {
            base.ClearItems();
        }
    }
}